package org.javagril.yuetong.controller.carriers;

import org.javagril.yuetong.service.CarriersService;
import org.javagril.yuetong.bean.Carriers;
import org.javagril.yuetong.bean.RespBean;
import org.javagril.yuetong.bean.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/carriers")
public class CarriersController {
    @Autowired
    CarriersService carriersService;

    /*查询所有承运信息*/
    @GetMapping("/")
    public RespPageBean getAllCarriers(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
        return carriersService.getAllCarriers(page, size);
    }


    /*添加承运信息*/
    @PostMapping("/")
    public RespBean addCarriers(@RequestBody Carriers carriers) {
        if (carriersService.addCarriers(carriers) == 1) {
            return RespBean.ok("承运单信息添加成功...o(*￣▽￣*)ブ");
        }
        return RespBean.error("承运单信息添加失败...(￣、￣)");
    }
}